(define (fold-left2 op initial sequence)
  (define (iter result rest)
    (if (null? rest)
        result
	(iter (op result (car rest))
	      (cdr rest))))
  (iter initial sequence))
(define (accumulate op initial sequence)
  (if (null? sequence)
    initial
    (op (car sequence)
        (accumulate op initial (cdr sequence)))))
(define (fold-right2 op initial sequence)
  (define (iter result rest)
    (if (null? rest)
        result
	(iter (op (last rest) result)
	      (except-last rest))))
  (iter initial sequence))
(define (last seq)
  (if (null? (cdr seq))
      (car seq)
      (last  (cdr seq))))
(define (except-last seq)
  (define (iter result rest)
    (if (null? (cdr rest))
        result
	(iter (cons (car rest) result) (cdr rest))))
  (reverse (iter '() seq)))
